﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using Model = Auto.Data.BusMan.Model;
using Auto.Data.BusMan.DALFactory;
using Auto.Data.BusMan.IDAL;
using Auto.Data.DBUtility;  //Please Add Reference First
namespace Auto.Data.BusMan.BLL
{
    /// <sumary> 
    /// BLL BusRelatedInfoRecheckHistory 
    /// </sumary> 
    public class BusRelatedInfoRecheckHistory
    {
        private readonly IBusRelatedInfoRecheckHistory dal = DataAccess<IBusRelatedInfoRecheckHistory>.CreateDALInstance("BusRelatedInfoRecheckHistory");
        #region --New--
        /// <sumary> 
        /// Constructed Function 
        /// </sumary> 
        public BusRelatedInfoRecheckHistory()
        {
        }
        /// <sumary> 
        /// Get Model 
        /// </sumary> 
        /// <param name="objKey">Key Of Table</param> 
        /// <returns>BusRelatedInfoRecheckHistory</returns> 
        public Model.BusRelatedInfoRecheckHistory GetModel(string busid, string type, DateTime typedate)
        {
            return dal.GetModel(busid, type, typedate);
        }
        /// <summary>
        /// Get Model, From Cache
        /// </summary>
        public BusRelatedInfoRecheckHistory GetModelByCache(string busid, string type, DateTime typedate)
        {
            string CacheKey = "BusRelatedInfoRecheckHistoryModel-" + busid + type + typedate;
            object objModel = Auto.Components.DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(busid, type, typedate);
                    if (objModel != null)
                    {
                        int ModelCache = Auto.Components.ConfigHelper.GetConfigInt("ModelCache");
                        Auto.Components.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return (BusRelatedInfoRecheckHistory)objModel;
        }
        #endregion --New--
        #region--Operate--
        /// <summary>
        /// Is Exists Or Not
        /// </summary>
        public bool Exists(string busid, string type, DateTime typedate)
        {
            return dal.Exists(busid, type, typedate);
        }
        #endregion--Operate--
        #region --SQL--
        /// <summary>
        /// Add One Record
        /// </summary>
        public void Add(Model.BusRelatedInfoRecheckHistory model)
        {
            dal.Add(model);
        }
        /// <summary>
        /// Update One Record
        /// </summary>
        public void Update(Model.BusRelatedInfoRecheckHistory model)
        {
            dal.Update(model);
        }
        /// <summary>
        /// Delete One Record
        /// </summary>
        public void Delete(string busid, string type, DateTime typedate)
        {
            dal.Delete(busid, type, typedate);
        }
        #endregion --SQL--
        #region --Get Data--
        /// <sumary> 
        ///  Get Data By Primary Key 
        /// </sumary> 
        /// <returns>DataTable</returns>
        public DataTable GetDataByKeyValue(string busid, string type, DateTime typedate)
        {
            return dal.GetDataByKeyValue(busid, type, typedate);
        }
        /// <summary>
        /// Get Data List
        /// </summary>
        /// <param name="strWhere">strWhere Format: ColName1='?' AND ColName2='?'...</param>
        public DataTable GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// Get Top N Datalist
        /// </summary>
        /// <param name="top">Top Rows</param>
        /// <param name="strWhere">strWhere Format: ColName1='?' AND ColName2='?'...</param>
        /// <param name="fieldOrder">ORDER BY FIELD,Format: ColName1,ColName2...ASC</param>
        public DataTable GetList(int top, string strWhere, string fieldOrder)
        {
            return dal.GetList(top, strWhere, fieldOrder);
        }
        /// <summary>
        /// Get Model List<BusRelatedInfoRecheckHistory>
        /// </summary>
        /// <param name="strWhere">strWhere Format: ColName1='?' AND ColName2='?'...</param>

        public List<Model.BusRelatedInfoRecheckHistory> GetModelList(string strWhere)
        {
            DataTable dt = dal.GetList(strWhere);
            return DataTableToList(dt);
        }
        /// <summary>
        /// GetMoelList By Table
        /// </summary>
        public List<Model.BusRelatedInfoRecheckHistory> DataTableToList(DataTable dt)
        {
            List<Model.BusRelatedInfoRecheckHistory> modelList = new List<Model.BusRelatedInfoRecheckHistory>();
            modelList = dal.DataTableToList(dt);
            return modelList;
        }
        /// <summary>
        /// Get ALL LIST
        /// </summary>
        public DataTable GetAllList()
        {
            return dal.GetList("");
        }
        ///// <summary>
        ///// Get Data By Pages
        ///// </summary>
        //public DataSet GetList(int pageSize,int pageIndex,string strWhere)
        //{
        //  return dal.GetList(pageSize,pageIndex,strWhere);
        //}

                /// <summary>
        /// 查询数据清单给报表--rptCarRelatedInfoRecheckHistory.rpt  车移保险，年审，营运证历史清单
        /// </summary>
        /// <param name="divID">单位编号</param>
        /// <param name="busIDNO">车辆牌号</param>
        /// <param name="startDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <param name="keywords">关键字</param>
        /// <returns>返回DT</returns>
        public DataTable GetListWithDesc(string divID, string busIDNO, string startDate, string endDate, string keywords)
        {
            return dal.GetListWithDesc(divID, busIDNO, startDate, endDate, keywords);
        }
        #endregion --Get Data--
    }
}
